<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/11/16
  Time: 17:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title> 管理中心 - 栏目列表 </title>
    <meta name="Copyright" content="Douco Design." />
    <link href="admin/css/public.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="admin/js/global.js"></script>
    <script type="text/javascript" src="adminjs/jquery.autotextarea.js"></script>
</head>
<body>
<div id="dcWrap">
   <%@include file="head.jsp"%>
    <!-- dcHead 结束 -->
       <%@include file="left.jsp"%>
    <div id="dcMain">
        <!-- 当前位置 -->
        <div id="urHere">DouPHP 管理中心<b>></b><strong>栏目列表</strong> </div>   <div class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3><a href="admin/categoryadd.jsp" class="actionBtn add">添加栏目</a>栏目列表</h3>
        <div id="list">
            <form name="action" action="admin/deleteAllServlet" method="post" onsubmit="return delSelectedItems();" >
                <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                    <tr>
                        <th width="22" align="center"><input name='chkall' type='checkbox' id='chkall' onclick='selectcheckbox(this.form)' value='check'></th>
                        <th width="40" align="center">编号</th>
                        <th align="left">栏目名称</th>

                        <th width="80" align="center">操作</th>
                    </tr>
                    <c:forEach items="${itemlist}" var="items" varStatus="itemstatus">
                    <tr>
                        <td align="center"><input type="checkbox" name="checkbox[]" value="${items.id}" /></td>
                        <td align="center">${itemstatus.count}</td>
                        <td><a href="admin/editItemsServlet?id=${items.id}">${items.itemname}</a></td>

                        <td align="center">
                            <a href="admin/editItemsServlet?id=${items.id}">编辑</a> | <a href="/admin/deleteItemsServlet?id=${items.id}" onclick="javascript:return delItems();">删除</a>
                        </td>
                    </tr>
                    </c:forEach>

                </table>

                <div class="action">

                    <input name="submit" class="btn" type="submit" value="删除所选记录"  />

                </div>
            </form>
        </div>
        <div class="clear"></div>

    </div>
        <div class="clear"></div>
        <%@include file="bottom.jsp"%><!-- dcFooter 结束 -->
        <div class="clear"></div> </div>
       <script type="text/javascript">
           function  delSelectedItems() {
               var  b=false;//默认没有选中
               for(var i=0;i<document.action.elements.length;i++){
                   var e=document.action.elements[i];
                   if(e.name!='chkall' && e.disabled!=true && e.name!='submit'){
                       if(e.checked){
                           b=true;
                           break;
                       }
                   }
               }
               if(!b){//如果没有选项被选中
                   alert("请选择要删除的栏目");
                   return false;
               }else {
                   if(confirm("是否删除所选记录")) {
                       return true;
                   }else {
                       return false;
                   }
               }
           }
           function  delItems() {
              if(confirm("是否删除所选记录")) {
                  return true;
              }else {
                  return false;
              }
           }

       </script>
</body>
</html>
